package com.itheima.string.Test2;

import java.util.Scanner;

/*
2、已知用户名和密码，请用程序实现模拟用户登录。总共给三次机会，是否登录成功，给出相应的提示。
 */
public class User {
    public static void main(String[] args) {
        for (int i = 1; i < 3; i++) {
            String username ="admin";
            String password ="123456";

            Scanner sc = new Scanner(System.in);
            System.out.println("请输入您的账号:");
            String userName = sc.nextLine();
            System.out.println("请输入您的密码:");
            String PassWord = sc.nextLine();

            if(username.equals(userName)&&password.equals(PassWord)){
                System.out.println("登录成功");
            }else if (i==3){
                System.out.println("今日登录错误已有3次,请明日尝试");
            }else{
                System.out.println("账号或密码错误,还有"+(3-i)+"次机会");
            }
        }

    }
}
